import java.util.stream.IntStream;

/**
 * @author DCSGO
 * @version 1.0
 */

public class TestStreamAndParallelStreamUseTime {
    public static void main(String[] args) {
        long t0 = System.nanoTime();
        int a[] = IntStream.range(0, 2_000_000_000).filter(p -> p % 17 == 0).toArray();
        long t1 = System.nanoTime();
        int b[] = IntStream.range(0, 2_000_000_000).parallel().filter(p -> p % 17 == 0).toArray();
        long t2 = System.nanoTime();
        System.out.printf(
                "顺序执行时间：%.2fs,并行执行时间：%.2fs%n",
                (t1 - t0) * 1e-9, (t2 - t1) * 1e-9);
        /*
         * 顺序执行时间：2.39s,并行执行时间：1.08s
         *
         * 进程已结束，退出代码为 0
         */
    }
}
